﻿@model string
@using Telerik.Web.Mvc.UI
@{
    int w = 285;
    int h = 200;
    List<string> allImages = new List<string>();
    List<string> allImagesBig = new List<string>();
    if (@Model != string.Empty && @Model != null)
    {
        string GalleryPath = Server.MapPath("~/Content/UserFiles/" + @Model + "/");
        if (!Directory.Exists(GalleryPath))
        {
            Directory.CreateDirectory(GalleryPath);
        }

        string RootPath = Server.MapPath("~");
        string[] AllFiles = Directory.GetFiles(Server.UrlDecode(GalleryPath));

        for (int i = 0; i < AllFiles.Length; i++)
        {
            AllFiles[i] = AllFiles[i].Replace(RootPath, "");
            AllFiles[i] = AllFiles[i].Replace("\\", "/").ToLower();
            if (AllFiles[i].EndsWith(".jpg") || AllFiles[i].EndsWith(".png") || AllFiles[i].EndsWith(".gif") || AllFiles[i].EndsWith(".bmp"))
            {
                allImages.Add("/Image?img=/" + HttpUtility.UrlEncode(AllFiles[i]) + "&w=" + w + "&h=" + h + "&t=0&c=0");
                allImagesBig.Add("/" + AllFiles[i]);
            }
        }
    }
}
<div class="gallery">
@{
    for (int i = 0; i < allImagesBig.Count; i++)
    {
        <text>
        <a href="@allImagesBig[i]" class="fancybox gallery_img_a"><img src="@allImages[i]" alt=""  class="gallery_img" /></a>
        </text>
    }
    <br class="clear" />
}
</div>
@{ Html.Telerik().ScriptRegistrar().OnDocumentReady(@<text> 
    $(".fancybox").fancybox({
        'overlayShow': true
    });
</text>); }